<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>一张订单的信息</title>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/Pub.css'/>"></link>
    <script type="text/javascript">
        var path = "<c:url value='/'/>";
    </script>

    <meta charset="utf-8">
    <title>Bootstrap 实例 - 条纹表格</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<p>选择/输入送货地址->订单明细-->选择/添加收货地址-><font color="red" style="font-family:bold;">确认订单</font>->网银付款或到货付款->查收货物</p>
<div>
    <form role="form" name="order" action="${pageContext.request.contextPath}/order_save.action" method="post">
        <div class="form-group">
            <table class="table table-striped">
                <caption>订单信息</caption>
                <thead>
                <tr>
                    <th>订单名称</th>
                    <th>订单结果</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        订单编号：
                    </td>
                    <td>
                        <input class="txt" readonly="readonly" type="text" name="id" id="id" value="${order.id}"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        收货人/地址：
                    </td>
                    <td>
                        <input class="txt" readonly="readonly" type="text" name="consignee" id="consignee" value="${order.consignee}"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        总金额：
                    </td>
                    <td>
                        <input style="text-align: center;" class="txt" readonly="readonly" type="text" name="amt"
                               id="amt"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        支付方式：
                    </td>
                    <td>
                        <select style="width:30%" multiple class="form-control" name="paytype" id="paytype">
                            <option value="1" selected="selected">货到付款</option>
                            <option value="2">在线支付</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    &nbsp;&nbsp;&nbsp;&nbsp;<td style="text-align:left;">
                    <button type="button" class="btn btn-primary btn-lg " onclick="sure();">确认订单</button>
                </td>
                </tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<table id="table" class="table table-striped">
    <caption>订单明细</caption>
    <thead>
    <tr>
        <th>书名</th>
        <th>价格</th>
        <th>数量</th>
        <th>合计</th>
    </tr>
    </thead>
    <tbody>
    <c:set value="0" var="sum"/>
    <c:forEach items="${sessionScope.car}" var="entry" varStatus="idx">
        <tr <c:if test="${idx.count%2==0}">class="even"</c:if>>
            <td>
                <a href="${pageContext.request.contextPath }/index_queryBook.action?id=${entry.value.id}">
                        ${entry.value.name}
                </a>
            </td>
            <td>
                    ${entry.value.currentPrice}元
            </td>
            <td>
                    ${entry.value.amt}本
            </td>
            <td>
                <fmt:formatNumber value="${entry.value.currentPrice*entry.value.amt}" pattern="#.##"/>
                <c:set value="${sum+(entry.value.currentPrice*entry.value.amt)}" var="sum"/>元
                <fmt:formatNumber value="${sum}" pattern="#.##" var="sum"/>
            </td>
        </tr>
    </c:forEach>
    <tr class="head">
        <td colspan="4" style="text-align:right;">
            总金额：
            <label id="sum">
                ${sum}
            </label>
            元
        </td>
    </tr>
    </tbody>
</table>
</body>
<script type="text/javascript">
    document.getElementById("amt").value = document.getElementById("sum").innerHTML;
    function sure() {
        var boo = window.confirm("确订要提交订单?");
        if (boo) {
            document.forms['order'].submit();
        }
    }
</script>
</html>
